ServerEvents.recipes((event) => {
    //待机配方
    event.recipes.custommachinery.custom_machine("eou:oil_fired_generator/stress_port", 20)
        .requireStructure([[
            "A",
            "m"
        ]], {
            "A": "eou:oil_fired_generator/controller"
        })
        .produceSU(256, 16384)
        .requireFunctionToStart((ctx) => {
            let level = ctx.block.minecraftLevel
            let pos = ctx.block.getPos()
            let facing = ctx.getBlock().getProperties().get("facing")
            //其他机器相对坐标
            let ports_pos = { fuel: [0, 0, -1] }
            switch (facing) {
                case "south":
                    break;
                case "west":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = -b;
                        ports_pos[key][2] = a;
                    }
                    break;
                case "north":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = -a;
                        ports_pos[key][2] = -b;
                    }
                    break;
                case "east":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = b;
                        ports_pos[key][2] = -a;
                    }
                    break;
            }
            let facing2 = level.getBlock(pos.x + ports_pos["fuel"][0], pos.y + ports_pos["fuel"][1], pos.z + ports_pos["fuel"][2]).getProperties().get("facing")
            if ((facing == "south" && facing2 != "north")
                || (facing == "west" && facing2 != "east")
                || (facing == "north" && facing2 != "south")
                || (facing == "east" && facing2 != "west")
            ) {
                return Result.error("no")
            }
            if (ctx.machine.data.work == 1)
                return Result.success()
            return Result.error("Not Working")
        })
        .resetOnError()
    //待机配方
    event.recipes.custommachinery.custom_machine("eou:oil_fired_generator/stress_port", 20)
        .requireStructure([[
            "A",
            "m"
        ]], {
            "A": "eou:oil_fired_generator/controller"
        })
        //.produceSU(256, 0)
        .requireFunctionToStart((ctx) => {
            let level = ctx.block.minecraftLevel
            let pos = ctx.block.getPos()
            let facing = ctx.getBlock().getProperties().get("facing")
            //其他机器相对坐标
            let ports_pos = { fuel: [0, 0, -1] }
            switch (facing) {
                case "south":
                    break;
                case "west":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = -b;
                        ports_pos[key][2] = a;
                    }
                    break;
                case "north":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = -a;
                        ports_pos[key][2] = -b;
                    }
                    break;
                case "east":
                    for (var key in ports_pos) {
                        let a = ports_pos[key][0]
                        let b = ports_pos[key][2]
                        ports_pos[key][0] = b;
                        ports_pos[key][2] = -a;
                    }
                    break;
            }
            let facing2 = level.getBlock(pos.x + ports_pos["fuel"][0], pos.y + ports_pos["fuel"][1], pos.z + ports_pos["fuel"][2]).getProperties().get("facing")
            if ((facing == "south" && facing2 != "north")
                || (facing == "west" && facing2 != "east")
                || (facing == "north" && facing2 != "south")
                || (facing == "east" && facing2 != "west")
            ) {
                return Result.error("no")
            }
            return Result.success()
        })
        .resetOnError()
    event.recipes.custommachinery.custom_machine("eou:oil_fired_generator/stress_port", 20)
        //.produceSU(256, 0)
        .requireFunctionEachTick((ctx) => {
            ctx.machine.data.work = 0
            return Result.success()
        })
        .resetOnError()
})